Repository navigation
telemetry: performance_monitor: fix manifest module entry offset - #11482
Open
Shrusti-pk wants to merge 1 commit into
Open
Shrusti-pk wants to merge 1 commit into
Shrusti-pk wants to merge 1 commit into
Conversation
enable_performance_counters() adds SOF_MAN_MODULE_OFFSET(mod_id), a byte offset, to a const struct sof_man_fw_desc pointer. The pointer arithmetic scales it by sizeof(struct sof_man_fw_desc), so module entry 0 is read 2704 bytes into the manifest instead of 52, and entry i at 52 * (52 + 116 * i). instance_max_count is then taken from unrelated memory past the manifest, which can fault or drive up to 65535 bogus ipc4_get_comp_dev() lookups per module, and the real instances are not reinitialized. It runs on every IPC4_PERF_MEASUREMENTS_STATE change to STOPPED, STARTED or PAUSED, for the base firmware manifest and every loaded library. Cast the descriptor to a byte pointer before adding the offset, as the other SOF_MAN_MODULE_OFFSET() users in lib_manager.c, llext_manager.c and helper-kernel.c already do.
Shrusti-pk
requested review from
dbaluta,
kv2019i,
lbetlej,
lgirdwood,
mmaka1 and
plbossart
as code owners
November 18, 2026 06:52
Collaborator
|
Can one of the admins verify this patch?
|
Member
|
test this please |
lgirdwood
requested changes
Nov 18, 2026
lgirdwood
left a comment
Member
There was a problem hiding this comment.
@Shrusti-pk pls make sure you add your SOB. You have several patches that are good enough to merge currently but are missing a SOB (and we cant merge without it).
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the manifest-addressing and const-qualification changes.
No open issues 🎉
What changed in this PR
Fixes manifest traversal in SOF’s performance monitor so re-enabling measurements reads the intended module entries when reinitializing component performance data.
Changes:
- Applies module offsets to a byte pointer, avoiding incorrect scaling by the descriptor size.
- Preserves const qualification when accessing module records.
| File | Description |
|---|---|
src/kernel/debug/telemetry/performance_monitor.c |
Corrects manifest module addressing and makes the module pointer const. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
enable_performance_counters()reads the wrong memory for every manifest module entry:descis aconst struct sof_man_fw_desc *, sodesc + SOF_MAN_MODULE_OFFSET(mod_id)scales the byte offset bysizeof(*desc)(52). Entry 0 is read atdesc + 2704instead ofdesc + 52, and entry i atdesc + 52 * (52 + 116 * i)instance_max_countcomes from that memory, so each module either faults or runs up to 65535ipc4_get_comp_dev()lookups on unrelated IDs, and the real instances never get their perf data reinitializedIPC4_PERF_MEASUREMENTS_STATEset to STOPPED, STARTED or PAUSED (set_perf_meas_state()), for the base FW manifest and every loaded librarySOF_MAN_MODULE_OFFSET()users (lib_manager.c, llext_manager.c, helper-kernel.c, base_fw_intel.c) already cast to a byte pointer firstChecked by building the function verbatim against a 3-module manifest laid out as rimage writes it: under ASan the old code is a heap-buffer-overflow READ 2380 bytes past the 400-byte manifest, and the fixed code reads entries at +52/+168/+284 and does the expected 15 lookups. I could not run it on hardware here.